/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gov.police.diary.command;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author nmduc
 */
public class SearchCommand {

    public static class Page {

        private String pageIndexLabel;
        private int pageIndex;

        public Page(String pageIndexLabel, int pageIndex) {
            this.pageIndex = pageIndex;
            this.pageIndexLabel = pageIndexLabel;
        }

        public int getPageIndex() {
            return pageIndex;
        }

        public void setPageIndex(int pageIndex) {
            this.pageIndex = pageIndex;
        }

        public String getPageIndexLabel() {
            return pageIndexLabel;
        }

        public void setPageIndexLabel(String pageIndexLabel) {
            this.pageIndexLabel = pageIndexLabel;
        }
    }

    public static class Column {

        private String columnName;
        private String fieldName;

        public Column(String columnName, String fieldName) {
            this.columnName = columnName;
            this.fieldName = fieldName;
        }

        public String getColumnName() {
            return columnName;
        }

        public void setColumnName(String columnName) {
            this.columnName = columnName;
        }

        public String getFieldName() {
            return fieldName;
        }

        public void setFieldName(String fieldName) {
            this.fieldName = fieldName;
        }
    }
    private String keywords;
    private long start;
    private long end;
    private long total;
    private long maxPerPage;
    private long currentPage;
    private Object[] result;
    private List<Page> pages;
    private List<Column> columns;
    private String header;
    private String searchAction;
    private Map<String, String> otherActions;
    public SearchCommand() {
        this.keywords = "";
        this.start = 0;
        this.end = 0;
        this.total = 0;
        this.result = null;
        this.currentPage = 0;
        this.maxPerPage = 10;
        this.pages = new ArrayList<Page>();
        this.header = "Time so dien thoai";
        this.searchAction = "search";
        this.otherActions = new HashMap<String, String>();
        //this.setColumns(createColumns());
    }

    private void updatePages() {
        long pageTotal = this.getTotal() / this.getMaxPerPage() + (this.getTotal() % this.getMaxPerPage() > 0 ? 1 : 0);
        this.pages.clear();
        for (int i = 0; i < pageTotal; i++) {
            this.pages.add(new Page("page " + i, i));
        }
    }

    public String getKeywords() {
        return keywords;
    }

    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }

    public long getEnd() {
        return end;
    }

    public void setEnd(long end) {
        this.end = end;
    }

    public Object[] getResult() {
        return result;
    }

    public void setResult(Object[] result) {
        this.result = result;
    }

    public long getStart() {
        return start;
    }

    public void setStart(long start) {
        this.start = start;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
        this.updatePages();
    }

    public long getMaxPerPage() {
        return maxPerPage;
    }

    public void setMaxPerPage(long maxPerPage) {
        this.maxPerPage = maxPerPage;
        this.updatePages();
    }

    public long getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(long currentPage) {
        this.currentPage = currentPage;
    }

    public List<Page> getPages() {
        return pages;
    }

    public void setPages(List<Page> pages) {
        this.pages = pages;
    }

    public List<Column> getColumns() {
        return columns;
    }

    public void setColumns(List<Column> columns) {
        this.columns = columns;
    }

    public String getHeader() {
        return header;
    }

    public void setHeader(String header) {
        this.header = header;
    }

    public Map<String, String> getOtherActions() {
        return otherActions;
    }

    public void setOtherActions(Map<String, String> otherActions) {
        this.otherActions = otherActions;
    }

    public String getSearchAction() {
        return searchAction;
    }

    public void setSearchAction(String searchAction) {
        this.searchAction = searchAction;
    }

   
}
